package com.wanxi.demo;

import com.wanxi.tool.Tool;

import java.util.Arrays;

public class CheckIndexFromArr {
    public static void main(String[] args) {
        int[] arr = Tool.getIntArr(10, 5);
        System.out.println(Arrays.toString(arr));
        int random = Tool.getRandom(5);
        System.out.println(random);

        boolean isHave = check(arr, random);
        if (!isHave)
            System.out.println("数组里面没有当前数字");

    }

    private static boolean check(int[] arr, int random) {
        boolean isHave = false;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == random) {
                System.out.println("当前数在数组里面的索引为:" + i);
                isHave = true;
            }
        }
        return isHave;
    }
}
